package org.example.controller;

import org.example.domain.InsertUniqueTable;
import org.example.service.IInsertUniqueTableService;
import org.example.service.impl.InsertUniqueTableServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.UUID;

/**
 * (insert_unique_table)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/insert_unique")
public class InsertUniqueTableController {
    private static final Logger log = LoggerFactory.getLogger(InsertUniqueTableController.class);
    /**
     * 服务对象
     */
    @Autowired
    private IInsertUniqueTableService insertUniqueTableService;

    @RequestMapping("/testInsertUnique")
    public int testInsertUnique() throws InterruptedException {
        UUID uuid = UUID.randomUUID();
        try {
            int i = insertUniqueTableService.testInsertUnique(uuid.toString());
            if (i > 0) {
                log.info("插入成功");
            } else {
                log.info("插入失败");
            }
            return i;
        }catch (Exception e){
            log.error("插入异常", e);
        }
        return 0;
    }

}
